<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Title1</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script src="<%=basePath %>web/js/jquery.min.js"></script>
    <script src="<%=basePath %>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath %>web/js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="<%=basePath %>web/themes/icon.css">
    <link rel="stylesheet" href="<%=basePath %>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>web/css/wu.css">
 </head>
     <script>
        var  selectIndex = -1;

        function hideTable(){
            $("#searchdiv").toggle();
        }
       $(function(){
        $("#reset_btn").click(function(){
             	$("#form1")[0].reset();
             	$("#productList").datagrid('load',serializeForm);
             })
                $("#productList").datagrid({
                url:'<%=basePath%>part/getPartList',
                pageNumber:1,
                pageSize:5,
                pageList:[5,10,15],
                pagination:true,
                checkOnSelect:true,
                columns:[[
                    {field:'ck',checkbox:true},
                    {field:'code',title:'配件单号',width:140},
                    {field:'partName',title:'配件名称',width:240},
                    {field:'typeName',title:'配件类别',width:100},
                    {field:'partBrand',title:'配件品牌',width:70},
                    {field:'partNo',title:'配件型号',width:80},
                    {field:'sellPrice',title:'销售单价',width:100,
                       formatter:function(value,row,index){
                            return "￥"+row.sellPrice;
                       }
                    },
                    {field:'memo',title:'备注',width:190}
                ]],
                toolbar:'#wu_toolbar',
                  onClickRow:function(index,row){
                	$(this).datagrid("unselectRow",index);
                },
            }) 
            
	       $("#search_btn").click(function(){
		       var form=$("#form1");
	  		 $("#productList").datagrid('load',serializeForm(form));
	        })
	        
           $('#partTypeId').combobox({    
	          url:'<%=basePath%>part/getAllpartType',    
	          valueField:'id',    
	          textField:'typeName'   
	       });  
	       
         
        })
          function addpart(){
	          var row = $('#productList').datagrid('getSelections');
     		  if(row!='' && row!=null){
	          parent.addpart(row);
     		  }
     		  $.messager.alert('我的消息','请选择配件!','warning');
     		  return;
       		}
        
	        function closePart(){
	           parent.closePart();
	        }
         //将表单序列化
		function serializeForm(form){
			var obj={};
			$.each(form.serializeArray(),function(index){
				  if(obj[this['name']]){
					obj[this['name']]=obj[this['name']]+','+this['value']
				 }else{
				   obj[this['name']]=this['value'];
				 }
			});
			return obj;
		} 
     </script>
  
  <body>
    <div id="wu_toolbar">
    <input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
    <div id="searchdiv" style="display: block;width: 100%;">
        <form name="form1" id="form1"> 
            <table width="100%" border="0" cellspacing="0" style="background-color:#c9dfff;" >
                <tbody><tr>
                    <td width="70" align="right">配件品牌:</td>
                    <td width="90" align="left"><input name="partBrand" class="easyui-textbox" type="text" id="findName" value="" maxlength="70" style="width:120px;height:30px"></td>
                    <td width="70" align="right">配件型号:</td>
                    <td width="90" align="left"><input name="partNo" class="easyui-textbox" type="text" id="findCode" value="" maxlength="70" style="width:120px;height:30px"></td>
                    <td width="100" align="right">配件名称:</td>
                    <td width="90" align="left"><input name="partName" class="easyui-textbox" type="text" id="findCode" value="" maxlength="70" style="width:120px;height:30px"></td>
                     <td width="70" align="right">类别:</td>
                    <td width="100" align="left">
                    <select name="partTypeId" id="partTypeId" class="easyui-combobox"  style="width:120px;height:30px" panelHeight="150px">
                    	
                    </select> 
                    </td>
                    <td width="72">
                        <a id="search_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
                    </td>
                    <td width="72">
                        <a id="reset_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-refresh'">重置</a>
                    </td>
                    <td width="0"></td>
                </tr>
                </tbody>
            </table>
            <input type="hidden" id="menuCode" value="100001001">
        </form>
    </div>
</div>
<div id="productList" class="easyui-datagrid">

</div>
<div id="addButton" style="float:right">
  <a href="javascript:addpart()" class="easyui-linkbutton" style="margin-right: 10px" data-options="iconCls:'icon-add'">添加配件</a>
  <a href="javascript:closePart()" class="easyui-linkbutton"  data-options="iconCls:'icon-delete3'">退出</a>
</div>
  </body>
</html>
